

<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
  <meta charset="utf-8" />
  <meta name="generator" content="Docutils 0.19: https://docutils.sourceforge.io/" />

  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  
  <title>映像在线迁移 &mdash; Ceph Documentation</title>
  

  
  <link rel="stylesheet" href="../../_static/ceph.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/ceph.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/graphviz.css" type="text/css" />
  <link rel="stylesheet" href="../../_static/css/custom.css" type="text/css" />

  
  

  
  

  

  
  <!--[if lt IE 9]>
    <script src="../../_static/js/html5shiv.min.js"></script>
  <![endif]-->
  
    
      <script type="text/javascript" id="documentation_options" data-url_root="../../" src="../../_static/documentation_options.js"></script>
        <script src="../../_static/jquery.js"></script>
        <script src="../../_static/_sphinx_javascript_frameworks_compat.js"></script>
        <script data-url_root="../../" id="documentation_options" src="../../_static/documentation_options.js"></script>
        <script src="../../_static/doctools.js"></script>
        <script src="../../_static/sphinx_highlight.js"></script>
    
    <script type="text/javascript" src="../../_static/js/theme.js"></script>

    
    <link rel="index" title="Index" href="../../genindex/" />
    <link rel="search" title="Search" href="../../search/" />
    <link rel="next" title="RBD 永久只读缓存" href="../rbd-persistent-read-only-cache/" />
    <link rel="prev" title="RBD 镜像" href="../rbd-mirroring/" /> 
</head>

<body class="wy-body-for-nav">

   
  <header class="top-bar">
    <div role="navigation" aria-label="Page navigation">
  <ul class="wy-breadcrumbs">
      <li><a href="../../" class="icon icon-home" aria-label="Home"></a></li>
          <li class="breadcrumb-item"><a href="../">Ceph 块设备</a></li>
          <li class="breadcrumb-item"><a href="../rbd-operations/">Ceph 块设备运维</a></li>
      <li class="breadcrumb-item active">映像在线迁移</li>
      <li class="wy-breadcrumbs-aside">
            <a href="../../_sources/rbd/rbd-live-migration.rst.txt" rel="nofollow"> View page source</a>
      </li>
  </ul>
  <hr/>
</div>
  </header>
  <div class="wy-grid-for-nav">
    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search"  style="background: #eee" >
          

          
            <a href="../../" class="icon icon-home"> Ceph
          

          
          </a>

          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../../search/" method="get">
    <input type="text" name="q" placeholder="Search docs" aria-label="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        
        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
              
            
            
              <ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../../start/">Ceph 简介</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../install/">安装 Ceph</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../cephadm/">Cephadm</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../rados/">Ceph 存储集群</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../cephfs/">Ceph 文件系统</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="../">Ceph 块设备</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="../rados-rbd-cmds/">基本命令</a></li>
<li class="toctree-l2 current"><a class="reference internal" href="../rbd-operations/">运维</a><ul class="current">
<li class="toctree-l3"><a class="reference internal" href="../rbd-snapshot/">快照</a></li>
<li class="toctree-l3"><a class="reference internal" href="../rbd-exclusive-locks/">互斥锁、独占锁</a></li>
<li class="toctree-l3"><a class="reference internal" href="../rbd-mirroring/">镜像</a></li>
<li class="toctree-l3 current"><a class="current reference internal" href="#">实时迁移</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#id2">准备迁移事宜</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id3">为单纯导入的迁移做准备</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id6">执行迁移</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id7">提交迁移</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id8">中止迁移</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="../rbd-persistent-read-only-cache/">永久只读缓存</a></li>
<li class="toctree-l3"><a class="reference internal" href="../rbd-persistent-write-log-cache/">永久写日志缓存</a></li>
<li class="toctree-l3"><a class="reference internal" href="../rbd-encryption/">加密</a></li>
<li class="toctree-l3"><a class="reference internal" href="../rbd-config-ref/">配置选项 (librbd)</a></li>
<li class="toctree-l3"><a class="reference internal" href="../rbd-replay/">RBD 重放</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../rbd-integrations/">对接</a></li>
<li class="toctree-l2"><a class="reference internal" href="../man/">手册页</a></li>
<li class="toctree-l2"><a class="reference internal" href="../api/">APIs</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../radosgw/">Ceph 对象网关</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../mgr/">Ceph 管理器守护进程</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../mgr/dashboard/">Ceph 仪表盘</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../monitoring/">监控概览</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../api/">API 文档</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../architecture/">体系结构</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../dev/developer_guide/">开发者指南</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../dev/internals/">Ceph 内幕</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../governance/">项目管理</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../foundation/">Ceph 基金会</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../ceph-volume/">ceph-volume</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../releases/general/">Ceph 版本（总目录）</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../releases/">Ceph 版本（索引）</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../security/">Security</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../hardware-monitoring/">硬件监控</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../glossary/">Ceph 术语</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../jaegertracing/">Tracing</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../translation_cn/">中文版翻译资源</a></li>
</ul>

            
          
        </div>
        
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" aria-label="top navigation">
        
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="../../">Ceph</a>
        
      </nav>


      <div class="wy-nav-content">
        
        <div class="rst-content">
        
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
<div id="dev-warning" class="admonition note">
  <p class="first admonition-title">Notice</p>
  <p class="last">This document is for a development version of Ceph.</p>
</div>
  <div id="docubetter" align="right" style="padding: 5px; font-weight: bold;">
    <a href="https://pad.ceph.com/p/Report_Documentation_Bugs">Report a Documentation Bug</a>
  </div>

  
  <section id="id1">
<h1>映像在线迁移<a class="headerlink" href="#id1" title="Permalink to this heading"></a></h1>
<p id="index-0">在同一集群内， RBD 映像可以在不同存储池之间在线迁移、
在不同映像格式和布局之间、或者从外部数据源迁移。
启动后，源映像会被深度复制到目标映像，
会拉取所有快照历史，同时尽可能保留稀疏分配的数据。</p>
<p>默认情况下，如果在线迁移的 RBD 映像们位于同一集群内，
源映像会被标记为只读，并且所有客户端会把 IO 重定向到新的目标映像。
另外，这个模式可以选择性地保留它到源映像的父映像的链接，
以保留稀疏数据块；或者可以在迁移映像时拍平映像，
以去除到源映像的父映像的依赖关系。</p>
<p>在线迁移进程还可以用在纯导入模式，
此时，源映像保持不变，而目标映像可以被链接到外部数据源，
像备份的文件、 HTTP(S) 文件、或者 S3 对象。</p>
<p>新的目标映像正在被使用时，
在线迁移复制进程可以安全地在后台运行。
当前，如果不是用纯导入模式操作，
在准备迁移前需要先暂时停止源映像的使用。
这是为了帮助确保客户端使用的映像和新的目标映像位于同一个更新点。</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>映像的在线迁移需要 Ceph Nautilus 或更高版本。
在 Ceph Pacific 或更高版本才支持外部数据源。
<code class="docutils literal notranslate"><span class="pre">krbd</span></code> 内核模块现在还不支持在线迁移。</p>
</div>
<p class="ditaa">
<img src="../../_images/ditaa-a81ef5525459bc60067594c82252ef3cc5426f94.png"/>
</p>
<p>在线迁移过程分三步：</p>
<ol class="arabic">
<li><p><strong>准备迁移（ Prepare Migration ）:</strong> 初始步骤，
会创建新的目标映像，并链接到源映像。
如果没配置成纯导入模式，源映像还会链接到目标映像，
并标记为只读。</p>
<p>与 <a class="reference external" href="../rbd-snapshot/#layering">分层映像</a> 相似，尝试读取目标映像内未初始化的数据区时，
会在程序内部把它重定向到源映像，
而写入目标映像内未初始化的数据区时，
程序内部会把重叠的源映像块深度复制到目标映像。</p>
</li>
<li><p><strong>执行迁移（ Execute Migration ）:</strong> 这是后台操作，
会把所有初始化的数据块从源映像深度复制到目标映像。
这一步可以在客户端们正使用新目标映像时运行。</p></li>
<li><p><strong>完成迁移（ Finish Migration ）:</strong>
后台迁移过程完成后，迁移操作可以提交或中止。
提交本次迁移会去除源和目标映像之间的链接，
如果不是在纯导入模式下，还会删除源映像。
中止迁移会删除交叉链接、并删除目标映像。</p></li>
</ol>
<section id="id2">
<h2>准备迁移事宜<a class="headerlink" href="#id2" title="Permalink to this heading"></a></h2>
<p>在同一一个 Ceph 集群内，映像的默认在线迁移过程由
<cite>rbd migration prepare</cite> 命令初始化，需提供源和目的映像：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ rbd migration prepare migration_source [migration_target]
</pre></div>
</div>
<p><cite>rbd migration prepare</cite> 命令支持的布局可选参数和
<cite>rbd create</cite> 命令的一样，可以用来更改不可变对象的磁盘布局。
如果只是为了更改磁盘上的布局，可以跳过 <cite>migration_target</cite> ，
还沿用最初的映像名。</p>
<p>在准备在线迁移前，所有使用这个源映像的客户端都必须先停止。
如果发现有客户端打开了客户端，不管是读还是写模式，
准备这步都会失败。准备步骤完成后，
客户端们可以用新的目标映像名重启。
仍然尝试用源映像名重启的客户端会失败。</p>
<p><cite>rbd status</cite> 命令可以显示在线迁移当前的状态：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ rbd status migration_target
Watchers: none
Migration:
            source: rbd/migration_source (5e2cba2f62e)
            destination: rbd/migration_target (5e2ed95ed806)
            state: prepared
</pre></div>
</div>
<p>注意，在迁移进程运行期间，源映像会被挪到 RBD 垃圾桶，
以免被误用：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ rbd info migration_source
rbd: error opening image migration_source: (2) No such file or directory
$ rbd trash ls --all
5e2cba2f62e migration_source
</pre></div>
</div>
</section>
<section id="id3">
<h2>为单纯导入的迁移做准备<a class="headerlink" href="#id3" title="Permalink to this heading"></a></h2>
<p>单纯导入（ import-only ）在线迁移进程同样是用 <cite>rbd migration prepare</cite> 命令初始化的，但是得加上 <cite>--import-only</cite> 选项，
还得提供一个 JSON 编码的 <code class="docutils literal notranslate"><span class="pre">source-spec</span></code> ，
用以描述如何访问源映像数据。这份 <code class="docutils literal notranslate"><span class="pre">source-spec</span></code>
可以直接用 <cite>--source-spec</cite> 选项传入、
或者通过 <cite>--source-spec-path</cite> 选项传入一个文件或 STDIN:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ rbd migration prepare --import-only --source-spec &quot;&lt;JSON&gt;&quot; migration_target
</pre></div>
</div>
<p><cite>rbd migration prepare</cite> 命令支持与 <cite>rbd create</cite> 命令相同的所有布局选项。</p>
<p><cite>rbd status</cite> 命令可以显示在线迁移当前的状态：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ rbd status migration_target
Watchers: none
Migration:
        source: {&quot;stream&quot;:{&quot;file_path&quot;:&quot;/mnt/image.raw&quot;,&quot;type&quot;:&quot;file&quot;},&quot;type&quot;:&quot;raw&quot;}
        destination: rbd/migration_target (ac69113dc1d7)
        state: prepared
</pre></div>
</div>
<p><code class="docutils literal notranslate"><span class="pre">source-spec</span></code> JSON 文件的通用格式如下：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">{</span>
    <span class="s2">&quot;type&quot;</span><span class="p">:</span> <span class="s2">&quot;&lt;format-type&gt;&quot;</span><span class="p">,</span>
    <span class="o">&lt;</span><span class="nb">format</span> <span class="n">unique</span> <span class="n">parameters</span><span class="o">&gt;</span>
    <span class="s2">&quot;stream&quot;</span><span class="p">:</span> <span class="p">{</span>
        <span class="s2">&quot;type&quot;</span><span class="p">:</span> <span class="s2">&quot;&lt;stream-type&gt;&quot;</span><span class="p">,</span>
        <span class="o">&lt;</span><span class="n">stream</span> <span class="n">unique</span> <span class="n">parameters</span><span class="o">&gt;</span>
    <span class="p">}</span>
<span class="p">}</span>
</pre></div>
</div>
<p>当前支持这几种格式： <code class="docutils literal notranslate"><span class="pre">native</span></code> 、 <code class="docutils literal notranslate"><span class="pre">qcow</span></code> 、和 <code class="docutils literal notranslate"><span class="pre">raw</span></code> 。
当前支持这几种流格式： <code class="docutils literal notranslate"><span class="pre">file</span></code> 、 <code class="docutils literal notranslate"><span class="pre">http</span></code> 、和 <code class="docutils literal notranslate"><span class="pre">s3</span></code> 。</p>
<section id="id4">
<h3>格式<a class="headerlink" href="#id4" title="Permalink to this heading"></a></h3>
<p><code class="docutils literal notranslate"><span class="pre">native</span></code> 格式用于描述与源映像位于同一集群内的本地 RBD 映像，
它的 <code class="docutils literal notranslate"><span class="pre">source-spec</span></code> JSON 编码成这样：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">{</span>
    <span class="s2">&quot;type&quot;</span><span class="p">:</span> <span class="s2">&quot;native&quot;</span><span class="p">,</span>
    <span class="s2">&quot;pool_name&quot;</span><span class="p">:</span> <span class="s2">&quot;&lt;pool-name&gt;&quot;</span><span class="p">,</span>
    <span class="p">[</span><span class="s2">&quot;pool_id&quot;</span><span class="p">:</span> <span class="o">&lt;</span><span class="n">pool</span><span class="o">-</span><span class="nb">id</span><span class="o">&gt;</span><span class="p">,]</span> <span class="p">(</span><span class="n">optional</span> <span class="n">alternative</span> <span class="n">to</span> <span class="s2">&quot;pool_name&quot;</span><span class="p">)</span>
    <span class="p">[</span><span class="s2">&quot;pool_namespace&quot;</span><span class="p">:</span> <span class="s2">&quot;&lt;pool-namespace&quot;</span><span class="p">,]</span> <span class="p">(</span><span class="n">optional</span><span class="p">)</span>
    <span class="s2">&quot;image_name&quot;</span><span class="p">:</span> <span class="s2">&quot;&lt;image-name&gt;&quot;</span><span class="p">,</span>
    <span class="p">[</span><span class="s2">&quot;image_id&quot;</span><span class="p">:</span> <span class="s2">&quot;&lt;image-id&gt;&quot;</span><span class="p">,]</span> <span class="p">(</span><span class="n">optional</span> <span class="k">if</span> <span class="n">image</span> <span class="ow">in</span> <span class="n">trash</span><span class="p">)</span>
    <span class="s2">&quot;snap_name&quot;</span><span class="p">:</span> <span class="s2">&quot;&lt;snap-name&gt;&quot;</span><span class="p">,</span>
    <span class="p">[</span><span class="s2">&quot;snap_id&quot;</span><span class="p">:</span> <span class="s2">&quot;&lt;snap-id&gt;&quot;</span><span class="p">,]</span> <span class="p">(</span><span class="n">optional</span> <span class="n">alternative</span> <span class="n">to</span> <span class="s2">&quot;snap_name&quot;</span><span class="p">)</span>
<span class="p">}</span>
</pre></div>
</div>
<p>需要注意的是， <code class="docutils literal notranslate"><span class="pre">native</span></code> 格式不包含 <code class="docutils literal notranslate"><span class="pre">stream</span></code> 对象，因为它利用的是
Ceph 的本地操作。例如，要从 <code class="docutils literal notranslate"><span class="pre">rbd/ns1/image1&#64;snap1</span></code> 映像导入，
对应的 <code class="docutils literal notranslate"><span class="pre">source-spec</span></code> 应该是：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">{</span>
    <span class="s2">&quot;type&quot;</span><span class="p">:</span> <span class="s2">&quot;native&quot;</span><span class="p">,</span>
    <span class="s2">&quot;pool_name&quot;</span><span class="p">:</span> <span class="s2">&quot;rbd&quot;</span><span class="p">,</span>
    <span class="s2">&quot;pool_namespace&quot;</span><span class="p">:</span> <span class="s2">&quot;ns1&quot;</span><span class="p">,</span>
    <span class="s2">&quot;image_name&quot;</span><span class="p">:</span> <span class="s2">&quot;image1&quot;</span><span class="p">,</span>
    <span class="s2">&quot;snap_name&quot;</span><span class="p">:</span> <span class="s2">&quot;snap1&quot;</span>
<span class="p">}</span>
</pre></div>
</div>
<p><code class="docutils literal notranslate"><span class="pre">qcow</span></code> 格式可以用于描述 QCOW (QEMU copy-on-write) 块设备。
当前， QCOW (v1) 和 QCOW2 格式都支持，除了一些高级功能，
如压缩、加密、 backing files 、和外部数据文件。
这些缺失的功能可能在以后的版本中加上。
<code class="docutils literal notranslate"><span class="pre">qcow</span></code> 格式的数据可以被链接到下文描述的任意 stream 源。
例如，它的基础 <code class="docutils literal notranslate"><span class="pre">source-spec</span></code> JSON 编码成这样：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">{</span>
    <span class="s2">&quot;type&quot;</span><span class="p">:</span> <span class="s2">&quot;qcow&quot;</span><span class="p">,</span>
    <span class="s2">&quot;stream&quot;</span><span class="p">:</span> <span class="p">{</span>
        <span class="o">&lt;</span><span class="n">stream</span> <span class="n">unique</span> <span class="n">parameters</span><span class="o">&gt;</span>
    <span class="p">}</span>
<span class="p">}</span>
</pre></div>
</div>
<p><code class="docutils literal notranslate"><span class="pre">raw</span></code> 格式可以用于描述一个完备配置的、 raw 块设备导出
（即 <cite>rbd export --export-format 1 &lt;snap-spec&gt;</cite> ）。
<code class="docutils literal notranslate"><span class="pre">raw</span></code> 格式的数据可以被链接到下文描述的任意 stream 源。
例如，它的基础 <code class="docutils literal notranslate"><span class="pre">source-spec</span></code> JSON 编码成这样：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>{
    &quot;type&quot;: &quot;raw&quot;,
    &quot;stream&quot;: {
        &lt;stream unique parameters for HEAD, non-snapshot revision&gt;
    },
    &quot;snapshots&quot;: [
        {
            &quot;type&quot;: &quot;raw&quot;,
            &quot;name&quot;: &quot;&lt;snapshot-name&gt;&quot;,
            &quot;stream&quot;: {
                &lt;stream unique parameters for snapshot&gt;
            }
        },
    ] (可选，按最老到最新排序的快照)
}
</pre></div>
</div>
<p><code class="docutils literal notranslate"><span class="pre">snapshots</span></code> 数组是可选的，而且当前仅支持全配 <code class="docutils literal notranslate"><span class="pre">raw</span></code> 快照的导出。</p>
<p>其它格式，像 RBD export-format v2 和
RBD export-diff 快照会在未来版本中增加。</p>
</section>
<section id="id5">
<h3>流格式<a class="headerlink" href="#id5" title="Permalink to this heading"></a></h3>
<p><code class="docutils literal notranslate"><span class="pre">file</span></code> 流可以用于从一个本地可访问的 POSIX 文件源导入。
它的 <code class="docutils literal notranslate"><span class="pre">source-spec</span></code> JSON 编码成这样：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">{</span>
    <span class="o">&lt;</span><span class="nb">format</span> <span class="n">unique</span> <span class="n">parameters</span><span class="o">&gt;</span>
    <span class="s2">&quot;stream&quot;</span><span class="p">:</span> <span class="p">{</span>
        <span class="s2">&quot;type&quot;</span><span class="p">:</span> <span class="s2">&quot;file&quot;</span><span class="p">,</span>
        <span class="s2">&quot;file_path&quot;</span><span class="p">:</span> <span class="s2">&quot;&lt;file-path&gt;&quot;</span>
    <span class="p">}</span>
<span class="p">}</span>
</pre></div>
</div>
<p>例如，要导入一个位于 /mnt/image.raw 、格式为 raw 的映像，
它的 <code class="docutils literal notranslate"><span class="pre">source-spec</span></code> JSON 编码成这样：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">{</span>
    <span class="s2">&quot;type&quot;</span><span class="p">:</span> <span class="s2">&quot;raw&quot;</span><span class="p">,</span>
    <span class="s2">&quot;stream&quot;</span><span class="p">:</span> <span class="p">{</span>
        <span class="s2">&quot;type&quot;</span><span class="p">:</span> <span class="s2">&quot;file&quot;</span><span class="p">,</span>
        <span class="s2">&quot;file_path&quot;</span><span class="p">:</span> <span class="s2">&quot;/mnt/image.raw&quot;</span>
    <span class="p">}</span>
<span class="p">}</span>
</pre></div>
</div>
<p><code class="docutils literal notranslate"><span class="pre">http</span></code> 流可以用于从远端 HTTP 或 HTTPS web 服务器导入。
它的 <code class="docutils literal notranslate"><span class="pre">source-spec</span></code> JSON 编码成这样：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">{</span>
    <span class="o">&lt;</span><span class="nb">format</span> <span class="n">unique</span> <span class="n">parameters</span><span class="o">&gt;</span>
    <span class="s2">&quot;stream&quot;</span><span class="p">:</span> <span class="p">{</span>
        <span class="s2">&quot;type&quot;</span><span class="p">:</span> <span class="s2">&quot;http&quot;</span><span class="p">,</span>
        <span class="s2">&quot;url&quot;</span><span class="p">:</span> <span class="s2">&quot;&lt;url-path&gt;&quot;</span>
    <span class="p">}</span>
<span class="p">}</span>
</pre></div>
</div>
<p>例如，要导入一个位于 <code class="docutils literal notranslate"><span class="pre">http://download.ceph.com/image.raw</span></code> 、
格式为 raw 的映像，它的 <code class="docutils literal notranslate"><span class="pre">source-spec</span></code> JSON 编码成这样：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">{</span>
    <span class="s2">&quot;type&quot;</span><span class="p">:</span> <span class="s2">&quot;raw&quot;</span><span class="p">,</span>
    <span class="s2">&quot;stream&quot;</span><span class="p">:</span> <span class="p">{</span>
        <span class="s2">&quot;type&quot;</span><span class="p">:</span> <span class="s2">&quot;http&quot;</span><span class="p">,</span>
        <span class="s2">&quot;url&quot;</span><span class="p">:</span> <span class="s2">&quot;http://download.ceph.com/image.raw&quot;</span>
    <span class="p">}</span>
<span class="p">}</span>
</pre></div>
</div>
<p><code class="docutils literal notranslate"><span class="pre">s3</span></code> 流可以用于从一个远端 S3 桶导入。
它的 <code class="docutils literal notranslate"><span class="pre">source-spec</span></code> JSON 编码成这样：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">{</span>
    <span class="o">&lt;</span><span class="nb">format</span> <span class="n">unique</span> <span class="n">parameters</span><span class="o">&gt;</span>
    <span class="s2">&quot;stream&quot;</span><span class="p">:</span> <span class="p">{</span>
        <span class="s2">&quot;type&quot;</span><span class="p">:</span> <span class="s2">&quot;s3&quot;</span><span class="p">,</span>
        <span class="s2">&quot;url&quot;</span><span class="p">:</span> <span class="s2">&quot;&lt;url-path&gt;&quot;</span><span class="p">,</span>
        <span class="s2">&quot;access_key&quot;</span><span class="p">:</span> <span class="s2">&quot;&lt;access-key&gt;&quot;</span><span class="p">,</span>
        <span class="s2">&quot;secret_key&quot;</span><span class="p">:</span> <span class="s2">&quot;&lt;secret-key&gt;&quot;</span>
    <span class="p">}</span>
<span class="p">}</span>
</pre></div>
</div>
<p>例如，要导入一个位于 <cite>http://s3.ceph.com/bucket/image.raw</cite> 、
格式为 raw 的映像，它的 <code class="docutils literal notranslate"><span class="pre">source-spec</span></code> JSON 编码成这样：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">{</span>
    <span class="s2">&quot;type&quot;</span><span class="p">:</span> <span class="s2">&quot;raw&quot;</span><span class="p">,</span>
    <span class="s2">&quot;stream&quot;</span><span class="p">:</span> <span class="p">{</span>
        <span class="s2">&quot;type&quot;</span><span class="p">:</span> <span class="s2">&quot;s3&quot;</span><span class="p">,</span>
        <span class="s2">&quot;url&quot;</span><span class="p">:</span> <span class="s2">&quot;http://s3.ceph.com/bucket/image.raw&quot;</span><span class="p">,</span>
        <span class="s2">&quot;access_key&quot;</span><span class="p">:</span> <span class="s2">&quot;NX5QOQKC6BH2IDN8HC7A&quot;</span><span class="p">,</span>
        <span class="s2">&quot;secret_key&quot;</span><span class="p">:</span> <span class="s2">&quot;LnEsqNNqZIpkzauboDcLXLcYaWwLQ3Kop0zAnKIn&quot;</span>
    <span class="p">}</span>
<span class="p">}</span>
</pre></div>
</div>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p><code class="docutils literal notranslate"><span class="pre">access_key</span></code> 和 <code class="docutils literal notranslate"><span class="pre">secret_key</span></code> 参数可以利用 MON 的 config-key 存储库，
引用时加 <code class="docutils literal notranslate"><span class="pre">config://</span></code> 前缀、然后是那个值在 MON config-key 库里的路径。
存入 config-key 库时可以用 <code class="docutils literal notranslate"><span class="pre">ceph</span> <span class="pre">config-key</span> <span class="pre">set</span> <span class="pre">&lt;key-path&gt;</span> <span class="pre">&lt;value&gt;</span></code> 命令，
（例如 <code class="docutils literal notranslate"><span class="pre">ceph</span> <span class="pre">config-key</span> <span class="pre">set</span> <span class="pre">rbd/s3/access_key</span> <span class="pre">NX5QOQKC6BH2IDN8HC7A</span></code> ）。</p>
</div>
</section>
</section>
<section id="id6">
<h2>执行迁移<a class="headerlink" href="#id6" title="Permalink to this heading"></a></h2>
<p>准备好在线迁移后，源映像里的数据块必须复制到目标映像。
要运行 <cite>rbd migration execute</cite> 命令来完成：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ rbd migration execute migration_target
Image migration: 100% complete...done.
</pre></div>
</div>
<p><cite>rbd status</cite> 命令可以反馈迁移数据块的深度复制进度：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ rbd status migration_target
Watchers:
    watcher=1.2.3.4:0/3695551461 client.123 cookie=123
Migration:
            source: rbd/migration_source (5e2cba2f62e)
            destination: rbd/migration_target (5e2ed95ed806)
            state: executing (32% complete)
</pre></div>
</div>
</section>
<section id="id7">
<h2>提交迁移<a class="headerlink" href="#id7" title="Permalink to this heading"></a></h2>
<p>在线迁移把所有数据块深度复制到目标映像之后，就可以提交这个迁移了：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ rbd status migration_target
Watchers: none
Migration:
            source: rbd/migration_source (5e2cba2f62e)
            destination: rbd/migration_target (5e2ed95ed806)
            state: executed
$ rbd migration commit migration_target
Commit image migration: 100% complete...done.
</pre></div>
</div>
<p>如果 <cite>migration_source</cite> 映像是一个或多个克隆品的父映像，
在确保所有派生出的映像都不在使用之后，需要加上 <cite>--force</cite> 选项。</p>
<p>提交在线迁移后，源和目标映像之间的交叉链接会被删除，
还会删除源映像：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ rbd trash list --all
</pre></div>
</div>
</section>
<section id="id8">
<h2>中止迁移<a class="headerlink" href="#id8" title="Permalink to this heading"></a></h2>
<p>如果你想回退准备或执行步骤，可以用 <cite>rbd migration abort</cite> 命令来回退迁移进程：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ rbd migration abort migration_target
Abort image migration: 100% complete...done.
</pre></div>
</div>
<p>中止迁移进程后，目标映像会被删除、
到源映像的访问会恢复：</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ rbd ls
migration_source
</pre></div>
</div>
</section>
</section>



<div id="support-the-ceph-foundation" class="admonition note">
  <p class="first admonition-title">Brought to you by the Ceph Foundation</p>
  <p class="last">The Ceph Documentation is a community resource funded and hosted by the non-profit <a href="https://ceph.io/en/foundation/">Ceph Foundation</a>. If you would like to support this and our other efforts, please consider <a href="https://ceph.io/en/foundation/join/">joining now</a>.</p>
</div>


           </div>
           
          </div>
          <footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer">
        <a href="../rbd-mirroring/" class="btn btn-neutral float-left" title="RBD 镜像" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
        <a href="../rbd-persistent-read-only-cache/" class="btn btn-neutral float-right" title="RBD 永久只读缓存" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
    </div>

  <hr/>

  <div role="contentinfo">
    <p>&#169; Copyright 2016, Ceph authors and contributors. Licensed under Creative Commons Attribution Share Alike 3.0 (CC-BY-SA-3.0).</p>
  </div>

   

</footer>
        </div>
      </div>

    </section>

  </div>
  

  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script>

  
  
    
   

</body>
</html>